﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ObserverPattern
{
    public abstract class Subject
    {
        protected ArrayList observers = new ArrayList();

        public void Attach(IObserver observer)
        {
            observers.Add(observer);
        }

        public void Detach(IObserver observer)
        {
            observers.Remove(observer);
        }
        public virtual void Notify()
        {
            foreach (IObserver observer in observers)
            {
                observer.Update();
            }
        }

    }
}
